/*
 * Copyright (C) 2010 LianHaidong <lianhaidong@gmail.com>
 */

#ifndef _EVENT_EVENT_H
#define _EVENT_EVENT_H

#include "utils/list.h"

struct event;

struct event_callback {
	struct list_head entry;
	int (*callback)(struct event *ev, void *args);
	void *args;
};

struct event_callback *event_cb_create(int (*cb)(struct event *, void *), void *args);

void event_cb_delete(struct event_callback *ev_cb);

struct event_type {
	EV_POLL_IN,
	EV_POLL_OUT,
};

struct event {
	struct list_head entry;
	uint64_t ts;
	struct connection *conn;
	struct task *task;
	struct list_head cb_list;

	enum event_type type;
};

void event_add_cb(struct event *ev, struct event_callback *cb);

struct event *event_create(enum event_type type);

void event_delete(struct event *ev);

#endif	/* _EVENT_EVENT_H */

